<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/9/8
 * Time: 20:16
 */
use yii\helpers\Html;
use app\controllers\CommentController;

?>
<style type="text/css">
    #comment-list-box
    {
        width:100%;
       font-family: "Microsoft Yahei", Tahoma, Arial;

    }
    .comment
    {
        list-style-type: none;
        display: block;
        width:100%;
        padding:0px 20px 20px 3%;

        background-color:#999;
        border:1px solid #ccc ;

        min-height:150px;
        box-sizing: border-box;







    }
    .comment-name
    {
        width:100%;
        height:26px;



    }
    .context
    {

        width:100%;
       height:100px;


    }
    .submit-box
    {
        width: 100%;
        height:26px;


    }
    .submit-box a
    {
        float:right;
        color:#333333;


    }
    .answer
    {
        width: 100%;

        padding-bottom: 20px;
        display: none;

    }
    .answer textarea
    {
        height:150px;
    }

</style>





<?=html::label('评论')?>
<?= Html::textarea('context','',['class'=>'form-control','id'=>'context'])?><br>
<?= Html::button('提交', ['class' => 'btn btn-primary','id'=>'submit']) ?>&nbsp;&nbsp;
<a href="http://localhost/basic/web/index.php?r=student/login" class="btn-primary btn">返回登录</a><br><br><br>
<label>全部评论</label>

<div id="comment-list-box">
    <?php for($i=0;$i<count($comment);$i++){
        if($comment[$i]['pid']==0){?>
            <ul class="comment" >
            <div class="comment-name" ><?=$comment[$i]['username']?> <?=$comment[$i]['time']?></div>
            <div class="context"><?=$comment[$i]['context']?></div>
            <div class="submit-box"><a  class="show" >回复</a></div>
            <div class="answer">
                <textarea class="form-control answer-context"></textarea>
                <br>
                <button class="btn btn-primary answer-submit" data-username="<?=$comment[$i]['username']?>" data-pid="<?=$comment[$i]['id']?>">提交</button>
            </div>
           <?php getList($comment,$i)?>
            </ul><?php }} ?>
</div>

<?php function getList($comment,$i)
{?>
   <?php  for($j=0;$j<count($comment);$j++){if($comment[$j]['pid']==$comment[$i]['id']&&$comment[$j]['pid']!=0){?>
         <ul class="comment" >
         <div class="comment-name" ><?=$comment[$j]['username']?> <?=$comment[$j]['time']?></div>
         <div class="context"><?=$comment[$j]['context']?></div>
         <div class="submit-box"><a  class="show" >回复</a></div>
         <div class="answer">
             <textarea class="form-control answer-context"></textarea>
             <br>
             <button class="btn btn-primary answer-submit" data-username="<?=$comment[$j]['username']?>" data-pid="<?=$comment[$j]['id']?>">提交</button>
         </div>
    <?php getList($comment,$j);?>
         </ul><?php }}
 } ?>




